/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.yunhoo.base.db.impl;

import com.yunhoo.base.model.Partner;
import com.yunhoo.base.model.Project;
import com.yunhoo.sys.db.util.IbatisTemplate;
import com.yunhoo.sys.util.common.LoginParam;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *
 * @author Administrator
 */
public class PartnerImpl {

    private static final String NAMESPACE = "partner.";

    public static void main(String args[]) {
        System.out.println(" * * * " + "selePartnerList : " + selePartnerList() + "  * * * ");
    }

    public static void insert(Partner partner) {
        IbatisTemplate.insert(NAMESPACE + "insertPartner", partner);
    }

    public static List selePartnerList() {
        
        Map map = new HashMap();
        map.put("orgCode",LoginParam.getOrg().getCode());
        return IbatisTemplate.queryForList(NAMESPACE + "partnerList", map);
    }

    public static List<Partner> queryAllByPro(Project pro) {
        
        Map map = new HashMap();
        map.put("orgCode",LoginParam.getOrg().getCode());
        map.put("projCode",pro.getCode());
        return IbatisTemplate.queryForList(NAMESPACE + "queryAllPartnerByPro", map);
    }

    public static List<Partner> queryNotInProj(Project pro) {
        
        Map map = new HashMap();
        map.put("orgCode",LoginParam.getOrg().getCode());
        map.put("projCode",pro.getCode());
        return IbatisTemplate.queryForList(NAMESPACE + "queryPartnerNotInProj", map);
    }

    public static List<Partner> checkIdRepeat(String id) {
        
        Map map = new HashMap();
        map.put("orgCode",LoginParam.getOrg().getCode());
        map.put("id",id);
        return IbatisTemplate.queryForList(NAMESPACE + "queryPartnerById", map);
    }

    public static void update(Partner partner) {
        IbatisTemplate.update(NAMESPACE + "updatePartner", partner);
    }

    public static void delete(Partner partner) {
        IbatisTemplate.delete(NAMESPACE + "deletePartnerById", partner);
    }

    public static List<String> checkUsing(Partner par) {
        
        Map map = new HashMap();
        map.put("orgCode",LoginParam.getOrg().getCode());
        map.put("id",par.getId());
        return IbatisTemplate.queryForList(NAMESPACE + "checkPartnerUsing", map);
    }

    public static List<String> checkCodeRepeat(Partner par) {
        
        Map map = new HashMap();
        map.put("orgCode",LoginParam.getOrg().getCode());
        map.put("id",par.getId());
        return IbatisTemplate.queryForList(NAMESPACE + "checkPartnerCodeRepeat", map);
    }

    public static Partner queryByPro(String projCode) {
        
        Map map = new HashMap();
        map.put("orgCode",LoginParam.getOrg().getCode());
        map.put("projCode",projCode);
        return (Partner) IbatisTemplate.query(NAMESPACE + "queryPartnerByPro", map);
    }
}
